home *** CD-ROM | disk | FTP | other *** search
/ Assassins - Ultimate CD Games Collection 4 / Assassins 4 (1999)(Weird Science).iso / misc / omega / source / scr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-02  |  35.1 KB  |  1,715 lines

  1. /* omega (c) 1987,1988,1989 by Laurence Raphael Brothers */
  2. /* scr.c */
  3. /* functions that use curses routines directly */
  4. /* plus a few file i/o stuff */
  5. /* also some in file.c */
  6.  
  7. #ifdef MSDOS
  8. # include "curses.h"
  9. #else
  10. # ifdef AMIGA
  11. # else
  12. #  include <curses.h>
  13. # endif
  14. # include <sys/types.h>
  15. #endif
  16.  
  17. #include "glob.h"
  18.  
  19. #ifdef EXCESSIVE_REDRAW
  20. #define wclear werase
  21. #endif
  22.  
  23.  
  24. /* note these variables are not exported to other files */
  25.  
  26. WINDOW *Levelw,*Dataw,*Flagw,*Timew,*Menuw,*Locw,*Morew,*Phasew;
  27. WINDOW *Comwin,*Msg1w,*Msg2w,*Msg3w,*Msgw;
  28. WINDOW *Showline[MAXITEMS];
  29.  
  30. #if !defined(MSDOS) && !defined(AMIGA)
  31. void wattrset ARGS((WINDOW *, int));
  32. #endif
  33.  
  34. void phaseprint()
  35. {
  36.   wclear(Phasew);
  37.   wprintw(Phasew,"Moon's Phase:\n");
  38.   switch(Phase/2) {
  39.   case 0: wprintw(Phasew,"NEW"); break;
  40.   case 1: case 11: wprintw(Phasew,"CRESCENT"); break;
  41.   case 2: case 10: wprintw(Phasew,"1/4"); break;
  42.   case 3: case 9: wprintw(Phasew,"HALF"); break;
  43.   case 4: case 8: wprintw(Phasew,"3/4"); break;
  44.   case 5: case 7: wprintw(Phasew,"GIBBOUS"); break;
  45.   case 6: wprintw(Phasew,"FULL"); break;
  46.   }
  47.   wrefresh(Phasew);
  48. }
  49.  
  50. void show_screen()
  51. {
  52.   int i,j,top,bottom;
  53.   int last_attr = 0, c;
  54.  
  55.   wclear(Levelw);
  56.   top = ScreenOffset;
  57.   bottom = ScreenOffset + ScreenLength;
  58.   top = max(0,top);
  59.   bottom = min(bottom,LENGTH);
  60.   if (Current_Environment != E_COUNTRYSIDE) 
  61.     for (j=top;j<bottom;j++) {
  62.       wmove(Levelw,screenmod(j),0);
  63.       for (i=0;i<WIDTH;i++) {
  64.     c = ((loc_statusp(i,j,SEEN)) ? getspot(i,j,FALSE):SPACE);
  65.         if (optionp(SHOW_COLOUR) && (c>>8) != last_attr) {
  66.           last_attr = c>>8;
  67.           wattrset(Levelw,last_attr);
  68.         }
  69.         waddch(Levelw,c&0xff);
  70.       }
  71.     }
  72.   else for (j=top;j<bottom;j++)
  73.       for (i=0;i<WIDTH;i++) {
  74.     wmove(Levelw,screenmod(j),i);
  75.         c = ((c_statusp(i,j,SEEN)) ? Country[i][j].current_terrain_type:SPACE);
  76.         if (optionp(SHOW_COLOUR) && (c>>8) != last_attr) {
  77.           last_attr = c>>8;
  78.           wattrset(Levelw,last_attr);
  79.         }
  80.         waddch(Levelw,c&0xff);
  81.       }
  82.   wrefresh(Levelw);
  83. }
  84.  
  85.  
  86.  
  87. char mgetc()
  88. {
  89.   return(wgetch(Msgw));
  90. }
  91.  
  92. /* case insensitive mgetc -- sends uppercase to lowercase */
  93. int mcigetc()
  94. {
  95.   int c;
  96.  
  97. #ifdef MSDOS
  98. #ifndef DJGPP
  99.   keypad(Msgw,TRUE);
  100. #endif
  101. #endif
  102.   c = wgetch(Msgw);
  103.   if ((c>=(int)'A') && (c<=(int)'Z'))
  104.     return(c+(int)('a'-'A'));
  105.   else return(c);
  106. }
  107.  
  108. char menugetc()
  109. {
  110.   return(wgetch(Menuw));
  111. }
  112.  
  113.  
  114. char lgetc()
  115. {
  116.   return(wgetch(Levelw));
  117. }
  118.  
  119.  
  120. char ynq()
  121. {
  122.   char p=' ';
  123.   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE))
  124.     p = wgetch(Msgw);
  125.   switch (p) {
  126.     case 'y': wprintw(Msgw,"yes. "); break;
  127.     case 'n': wprintw(Msgw,"no. "); break;
  128.     case ESCAPE: p = 'q';
  129.     case 'q': wprintw(Msgw,"quit. "); break;
  130.     }
  131.   wrefresh(Msgw);
  132.   return(p);
  133. }
  134.  
  135.  
  136. char ynq1()
  137. {
  138.   char p=' ';
  139.   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE))
  140.     p = wgetch(Msg1w);
  141.   switch (p) {
  142.     case 'y': wprintw(Msg1w,"yes. "); break;
  143.     case 'n': wprintw(Msg1w,"no. "); break;
  144.     case ESCAPE: p = 'q';
  145.     case 'q': wprintw(Msg1w,"quit. "); break;
  146.     }
  147.   wrefresh(Msg1w);
  148.   return(p);
  149. }
  150.  
  151.  
  152. char ynq2()
  153. {
  154.   char p=' ';
  155.   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE))
  156.     p = wgetch(Msg2w);
  157.   switch (p) {
  158.     case 'y': wprintw(Msg2w,"yes. "); break;
  159.     case 'n': wprintw(Msg2w,"no. "); break;
  160.     case ESCAPE: p = 'q';
  161.     case 'q': wprintw(Msg2w,"quit. "); break;
  162.     }
  163.   wrefresh(Msg2w);
  164.   return(p);
  165. }
  166.     
  167. /* puts up a morewait to allow reading if anything in top two lines */
  168. void checkclear()
  169. {
  170.   int x1,y,x2;
  171.   getyx(Msg1w,&x1,&y);
  172.   getyx(Msg2w,&x2,&y);  
  173.   if ((x1 != 0) || (x2 != 0)) {
  174.     morewait();
  175.     wclear(Msg1w);
  176.     wclear(Msg2w);
  177.     wrefresh(Msg1w);
  178.     wrefresh(Msg2w);
  179.   }
  180. }
  181.   
  182. /* for external call */
  183. void clearmsg()
  184. {
  185.   wclear(Msg1w);
  186.   wclear(Msg2w);
  187.   wclear(Msg3w);
  188.   Msgw = Msg1w;
  189.   wrefresh(Msg1w);
  190.   wrefresh(Msg2w);
  191.   wrefresh(Msg3w);
  192. }
  193.  
  194. void clearmsg3()
  195. {
  196.   wclear(Msg3w);
  197.   wrefresh(Msg3w);
  198. }
  199.  
  200. void clearmsg1()
  201. {
  202.   wclear(Msg1w);
  203.   wclear(Msg2w);
  204.   Msgw = Msg1w;
  205.   wrefresh(Msg1w);
  206.   wrefresh(Msg2w);
  207. }
  208.  
  209.  
  210. void erase_level()
  211. {
  212.   wclear(Levelw);
  213.   wrefresh(Levelw);
  214. }
  215.  
  216. /* direct print to first msg line */
  217. void print1(s)
  218. char *s;
  219. {
  220.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  221.     buffercycle(s);
  222.     wclear(Msg1w);
  223.     wprintw(Msg1w,s);
  224.     wrefresh(Msg1w);
  225.   }
  226. }
  227.  
  228. /* for run on-messages -- print1 clears first.... */
  229. void nprint1(s)
  230. char *s;
  231. {
  232.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  233.     if (bufferappend(s)) {
  234.       wprintw(Msg1w,s);
  235.       wrefresh(Msg1w);
  236.     }
  237.   }
  238. }
  239.  
  240.  
  241.  
  242.  
  243. /* direct print to second msg line */
  244. void print2(s)
  245. char *s;
  246. {
  247.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  248.     buffercycle(s);
  249.     wclear(Msg2w);
  250.     wprintw(Msg2w,s);
  251.     wrefresh(Msg2w);
  252.   }
  253. }
  254.  
  255. /* for run on-messages -- print2 clears first.... */
  256. void nprint2(s)
  257. char *s;
  258. {
  259.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  260.     if (bufferappend(s)) {
  261.       wprintw(Msg2w,s);
  262.       wrefresh(Msg2w);
  263.     }
  264.   }
  265. }
  266.  
  267.  
  268.  
  269.  
  270. /* msg line 3 is not part of the region that mprint or printm can reach */
  271. /* typical use of print3 is for "you can't do that" type error messages */
  272. void print3(s)
  273. char *s;
  274. {
  275.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  276.     buffercycle(s);
  277.     wclear(Msg3w);
  278.     wprintw(Msg3w,s);
  279.     wrefresh(Msg3w);
  280.   }
  281. }
  282.  
  283. /* for run on-messages -- print3 clears first.... */
  284. void nprint3(s)
  285. char *s;
  286. {
  287.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  288.     if (bufferappend(s)) {
  289.       wprintw(Msg3w,s);
  290.       wrefresh(Msg3w);
  291.     }
  292.   }
  293. }
  294.  
  295.  
  296.  
  297. /* prints wherever cursor is in window, but checks to see if
  298. it should morewait and clear window */
  299. void mprint(s)
  300. char *s;
  301. {
  302.   int x,y;
  303.   if (! gamestatusp(SUPPRESS_PRINTING)) {
  304.     getyx(Msgw,&y,&x);
  305.     if (x+strlen(s) >= WIDTH) {
  306.       buffercycle(s);
  307.       if (Msgw == Msg1w) {
  308.     wclear(Msg2w);
  309.     Msgw = Msg2w;
  310.       }
  311.       else {
  312.     morewait();
  313.     wclear(Msg1w);
  314.     wclear(Msg2w);
  315.     wrefresh(Msg2w);
  316.     Msgw = Msg1w;
  317.       }
  318.     }
  319.     else if (x > 0)
  320.       bufferappend(s);
  321.     else
  322.       buffercycle(s);
  323.     wprintw(Msgw,s);
  324.     waddch(Msgw,' '); 
  325.     wrefresh(Msgw);
  326.   }
  327. }
  328.  
  329.  
  330.  
  331.  
  332. void title()
  333. {
  334.   showmotd();
  335.   clear();
  336.   touchwin(stdscr);
  337.   refresh();  
  338.   showscores();
  339. }
  340.  
  341.  
  342.  
  343.  
  344.  
  345. /* blanks out ith line of Menuw or Levelw */
  346. void hide_line(i)
  347. int i;
  348. {
  349.   wclear(Showline[i]);
  350.   touchwin(Showline[i]);
  351.   wrefresh(Showline[i]);
  352. }
  353.  
  354.  
  355.  
  356. /* initialize, screen, windows */
  357. void initgraf()
  358. {
  359.   int i;
  360.   initscr();
  361.   if (LINES < 24 || COLS < 80) {
  362.     printf("Minimum Screen Size: 24 Lines by 80 Columns.");
  363.     exit(0);
  364.   }
  365.   ScreenLength = LINES - 6;
  366.   Msg1w = newwin(1,80,0,0);
  367.   scrollok(Msg1w, 0);    /* DJGPP curses defaults to scrollable new windows */
  368.   Msg2w = newwin(1,80,1,0);
  369.   scrollok(Msg2w, 0);
  370.   Msg3w = newwin(1,80,2,0);
  371.   scrollok(Msg3w, 0);
  372.   Msgw = Msg1w;
  373.   Morew = newwin(1,15,3,65);  
  374.   scrollok(Morew, 0);
  375.   Locw = newwin(1,80,ScreenLength+3,0);
  376.   scrollok(Locw, 0);
  377.   Levelw = newwin(ScreenLength,64,3,0);
  378.   scrollok(Levelw, 0);
  379.   for(i=0;i<MAXITEMS;i++) {
  380.     Showline[i] = newwin(1,64,i+3,0);
  381.     scrollok(Showline[i], 0);
  382.     wclear(Showline[i]);
  383.   }
  384.   Menuw = newwin(ScreenLength,64,3,0);
  385.   scrollok(Menuw, 0);
  386.   Dataw = newwin(2,80,ScreenLength+4,0);
  387.   scrollok(Dataw, 0);
  388.   Timew = newwin(2,15,4,65);
  389.   scrollok(Timew, 0);
  390.   Phasew = newwin(2,15,6,65);
  391.   scrollok(Phasew, 0);
  392.   Flagw = newwin(4,15,9,65);
  393.   scrollok(Flagw, 0);
  394.   Comwin = newwin(8,15,14,65);
  395.   scrollok(Comwin, 0);
  396.  
  397.   noecho();
  398.   crmode();
  399.  
  400.   clear();
  401.   touchwin(stdscr);
  402.   title();
  403.   clear();
  404.   touchwin(stdscr);
  405.   refresh();
  406. }
  407.  
  408.  
  409.  
  410.  
  411.  
  412. int lastx= -1,lasty= -1;
  413.  
  414. void drawplayer()
  415. {
  416.   int c;
  417.  
  418.   if (Current_Environment == E_COUNTRYSIDE) {
  419.     if (inbounds(lastx,lasty) && !offscreen(lasty)) {
  420.     wmove(Levelw,screenmod(lasty),lastx);
  421.         c = Country[lastx][lasty].current_terrain_type;
  422.         if (optionp(SHOW_COLOUR))
  423.           wattrset(Levelw, c>>8);
  424.         waddch(Levelw,(c&0xff));
  425.     }
  426.     wmove(Levelw,screenmod(Player.y),Player.x);
  427.     if (optionp(SHOW_COLOUR))
  428.       wattrset(Levelw, PLAYER>>8);
  429.     waddch(Levelw,(PLAYER&0xff));
  430.   }
  431.   else {
  432.     if (inbounds(lastx,lasty) && !offscreen(lasty))
  433.       plotspot(lastx,lasty,(Player.status[BLINDED]>0 ? FALSE : TRUE));
  434.     wmove(Levelw,screenmod(Player.y),Player.x);
  435.     if ((! Player.status[INVISIBLE]) || Player.status[TRUESIGHT]) {
  436.       if (optionp(SHOW_COLOUR))
  437.         wattrset(Levelw, PLAYER>>8);
  438.       waddch(Levelw,(PLAYER&0xff));
  439.     }
  440.   }
  441.   lastx = Player.x;
  442.   lasty = Player.y;
  443. }
  444.  
  445. void setlastxy(new_x, new_y) /* used when changing environments */
  446. int new_x, new_y;
  447. {
  448.     lastx = new_x;
  449.     lasty = new_y;
  450. }
  451.  
  452. int litroom(x,y)
  453. int x,y;
  454. {
  455.   if (Level->site[x][y].roomnumber < ROOMBASE) return(FALSE);
  456.   else return(loc_statusp(x,y,LIT) ||
  457.           Player.status[ILLUMINATION]);
  458. }
  459.  
  460. void drawvision(x,y)
  461. int x,y;
  462. {
  463.   static int oldx = -1,oldy = -1;
  464.   int i,j,c;
  465.  
  466.   if (Current_Environment != E_COUNTRYSIDE) {
  467.     if (Player.status[BLINDED]) {
  468.       drawspot(oldx,oldy);
  469.       drawspot(x,y);
  470.       drawplayer();
  471.     }
  472.     else {
  473.       if (Player.status[ILLUMINATION] > 0) {
  474.     for (i= -2;i<3;i++)
  475.       for (j= -2;j<3;j++)
  476.         if (inbounds(x+i,y+j))
  477.           if (view_los_p(x+i,y+j,Player.x,Player.y))
  478.         dodrawspot(x+i,y+j);
  479.       }
  480.       else {
  481.     for (i= -1;i<2;i++)
  482.       for (j= -1;j<2;j++)
  483.         if (inbounds(x+i,y+j))
  484.           dodrawspot(x+i,y+j);
  485.       }
  486.       drawplayer();
  487.       drawmonsters(FALSE); /* erase all monsters */
  488.       drawmonsters(TRUE);  /* draw those now visible */
  489.     }
  490.     if ((! gamestatusp(FAST_MOVE)) || (! optionp(JUMPMOVE)))
  491.       omshowcursor(Player.x,Player.y);
  492.     oldx = x;
  493.     oldy = y;
  494.   }
  495.   else {
  496.     for (i= -1;i<2;i++)
  497.       for (j= -1;j<2;j++)
  498.     if (inbounds(x+i,y+j)) {
  499.       c_set(x+i, y+j, SEEN);
  500.       if (!offscreen(y+j)) {
  501.         wmove(Levelw,screenmod(y+j),x+i);
  502.             c = Country[x+i][y+j].current_terrain_type;
  503.             if (optionp(SHOW_COLOUR))
  504.               wattrset(Levelw, c>>8);
  505.             waddch(Levelw,(c&0xff));
  506.       }
  507.     }
  508.     drawplayer();
  509.     omshowcursor(Player.x,Player.y);
  510.   }
  511. }
  512.  
  513.  
  514. void omshowcursor(x,y)
  515. int x,y;
  516. {
  517.   if (! offscreen(y)) {
  518.     wmove(Levelw,screenmod(y),x);
  519.     wrefresh(Levelw);
  520.   }
  521. }
  522.  
  523. void levelrefresh()
  524. {
  525.   wrefresh(Levelw);
  526. }
  527.  
  528.  
  529. /* draws a particular spot under if in line-of-sight */
  530. void drawspot(x,y)
  531. int x,y;
  532. {
  533.   short c;
  534.   if (inbounds(x,y)) {
  535.     c = getspot(x,y,FALSE);
  536.     if (c != Level->site[x][y].showchar)
  537.       if (view_los_p(Player.x,Player.y,x,y)) {
  538.     lset(x,y,SEEN);
  539.     Level->site[x][y].showchar = c;
  540.     putspot(x,y,c);
  541.       }
  542.   }
  543. }
  544.  
  545.  
  546.  
  547. /* draws a particular spot regardless of line-of-sight */
  548. void dodrawspot(x,y)
  549. int x,y;
  550. {
  551.   short c;
  552.   if (inbounds(x,y)) {
  553.     c = getspot(x,y,FALSE);
  554.     if (c != Level->site[x][y].showchar) {
  555.       lset(x,y,SEEN);
  556.       Level->site[x][y].showchar = c;
  557.       putspot(x,y,c);
  558.     }
  559.   }
  560. }
  561.  
  562. /* write a blank to a spot if it is floor */
  563. void blankoutspot(i,j)
  564. int i,j;
  565. {
  566.   if (inbounds(i,j)) {
  567.     lreset(i,j,LIT);
  568.     lset(i, j, CHANGED);
  569.     if (Level->site[i][j].locchar == FLOOR)  {
  570.       Level->site[i][j].showchar = SPACE;
  571.       putspot(i,j,SPACE);
  572.     }
  573.   }
  574. }
  575.  
  576. /* blank out a spot regardless */
  577. void blotspot(i,j)
  578. int i,j;
  579. {
  580.   if (inbounds(i,j)) {
  581.     lreset(i,j,SEEN);
  582.     Level->site[i][j].showchar = SPACE;
  583.     if (! offscreen(j)) {
  584.       wmove(Levelw,screenmod(j),i);
  585.       wattrset(Levelw, SPACE>>8);
  586.       waddch(Levelw, SPACE&0xff);
  587.     }
  588.   }
  589. }
  590.  
  591.  
  592. /* for displaying activity specifically at some point */
  593. void plotspot(x,y,showmonster)
  594. int x,y,showmonster;
  595. {
  596.   if (loc_statusp(x,y,SEEN))
  597.     putspot(x,y,getspot(x,y,showmonster));
  598.   else 
  599.     putspot(x,y,SPACE);
  600. }
  601.  
  602.  
  603. /* Puts c at x,y on screen. No fuss, no bother. */
  604. void putspot(x,y,c)
  605. int x,y;
  606. short c;
  607. {
  608.   if (! offscreen(y)) {
  609.     wmove(Levelw,screenmod(y),x);
  610.     if (optionp(SHOW_COLOUR))
  611.       wattrset(Levelw, c>>8);
  612.     waddch(Levelw,(0xff&c));
  613.   }
  614. }
  615.  
  616.  
  617. /* regardless of line of sight, etc, draw a monster */
  618. void plotmon(m)
  619. struct monster *m;
  620. {
  621.   if (! offscreen(m->y)) {
  622.     wmove(Levelw,screenmod(m->y),m->x);
  623.     if (optionp(SHOW_COLOUR))
  624.       wattrset(Levelw, m->monchar>>8);
  625.     waddch(Levelw,(m->monchar&0xff));
  626.   }
  627. }
  628.   
  629. /* if display, displays monsters, otherwise erases them */
  630. void drawmonsters(display)
  631. int display;
  632. {
  633.   pml ml;
  634.   for (ml=Level->mlist;ml!=NULL;ml=ml->next) {
  635.     if (ml->m->hp > 0) {
  636.       if (display) {
  637.     if (view_los_p(Player.x,Player.y,ml->m->x,ml->m->y)) {
  638.       if (Player.status[TRUESIGHT] || (! m_statusp(ml->m,M_INVISIBLE))) {
  639.         if (!optionp(SHOW_COLOUR) &&
  640.             (ml->m->level > 5) &&
  641.         ((ml->m->monchar&0xff) != '@') &&
  642.         ((ml->m->monchar&0xff) != '|')) wstandout(Levelw);
  643.         putspot(ml->m->x,ml->m->y,ml->m->monchar);
  644.         if (!optionp(SHOW_COLOUR))
  645.           wstandend(Levelw);
  646.       }
  647.     }
  648.       }
  649.       else erase_monster(ml->m);
  650.     }
  651.   }
  652. }
  653.  
  654. /* replace monster with what would be displayed if monster weren't there */
  655. void erase_monster(m)
  656. struct monster *m;
  657. {
  658.   if (loc_statusp(m->x,m->y,SEEN))
  659.     putspot(m->x,m->y,getspot(m->x,m->y,FALSE));
  660.   else blotspot(m->x,m->y);
  661. }
  662.  
  663. /* find apt char to display at some location */
  664. short getspot(x,y,showmonster)
  665. int x,y,showmonster;
  666. {
  667.   if (loc_statusp(x,y,SECRET)) return(WALL);
  668.   else switch (Level->site[x][y].locchar) {
  669.   case WATER:
  670.     if (Level->site[x][y].creature == NULL) 
  671.       return(WATER);
  672.     else if (m_statusp(Level->site[x][y].creature,SWIMMING))
  673.       return(WATER);
  674.     else if (showmonster)
  675.       return(Level->site[x][y].creature->monchar);
  676.     else return(WATER);
  677.   /* these sites never show anything but their location char's */
  678.   case CLOSED_DOOR:
  679.   case LAVA:
  680.   case FIRE:
  681.   case ABYSS:
  682.     return(Level->site[x][y].locchar);
  683.   /* rubble and hedge don't show items on their location */
  684.   case RUBBLE:
  685.   case HEDGE:
  686.     if (showmonster && (Level->site[x][y].creature != NULL)) {
  687.       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
  688.       (! Player.status[TRUESIGHT]))
  689.     return(getspot(x,y,FALSE));
  690.       else return (Level->site[x][y].creature->monchar);
  691.     }
  692.     else return(Level->site[x][y].locchar);
  693.   /* everywhere else, first try to show monster, next show items, next show
  694.      location char */
  695.   default:
  696.     if (showmonster && (Level->site[x][y].creature != NULL)) {
  697.       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
  698.       (! Player.status[TRUESIGHT]))
  699.     return(getspot(x,y,FALSE));
  700.       else return (Level->site[x][y].creature->monchar);
  701.     }
  702.     else if (Level->site[x][y].things != NULL) {
  703.       if (Level->site[x][y].things->next != NULL)
  704.     return(PILE);
  705.       else return(Level->site[x][y].things->thing->objchar);
  706.     }
  707.     else return(Level->site[x][y].locchar);
  708.   }
  709. }
  710.  
  711. void commanderror()
  712. {
  713.   wclear(Msg3w);
  714.   wprintw(Msg3w,"%c : unknown command",Cmd);
  715.   wrefresh(Msg3w);
  716. }
  717.  
  718. void timeprint()
  719. {
  720.   wclear(Timew);
  721.   wprintw(Timew,"%d:%d",showhour(),showminute());
  722.   if (showminute()==0) waddch(Timew,'0');
  723.   wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
  724.   wprintw(Timew,month());
  725.   wprintw(Timew," the %d",day());
  726.   wprintw(Timew,ordinal(day()));
  727.   wrefresh(Timew);
  728. }
  729.  
  730.  
  731. void comwinprint()
  732. {
  733.   wclear(Comwin);
  734.   wprintw(Comwin,"Hit: %d  \n",Player.hit);
  735.   wprintw(Comwin,"Dmg: %d  \n",Player.dmg);
  736.   wprintw(Comwin,"Def: %d  \n",Player.defense);
  737.   wprintw(Comwin,"Arm: %d  \n",Player.absorption);
  738.   wprintw(Comwin,"Spd: %d.%d  \n", 5/Player.speed, 500/Player.speed%100);
  739.   wrefresh(Comwin);
  740. }
  741.  
  742. void dataprint()
  743. {
  744.   wclear(Dataw);
  745.   wprintw(Dataw,"HP:%d/%d MANA:%ld/%ld AU:%ld LEVEL:%d/%ld CARRY:%d/%d \n",
  746.       Player.hp,Player.maxhp,Player.mana,Player.maxmana,Player.cash,
  747.       Player.level,Player.xp,Player.itemweight,Player.maxweight);
  748.   wprintw(Dataw,"STR:%d/%d CON:%d/%d DEX:%d/%d AGI:%d/%d INT:%d/%d POW:%d/%d   ",
  749.       Player.str,Player.maxstr,Player.con,Player.maxcon,
  750.       Player.dex,Player.maxdex,Player.agi,Player.maxagi,
  751.       Player.iq,Player.maxiq,Player.pow,Player.maxpow);
  752.   wrefresh(Dataw);
  753. }
  754.  
  755.  
  756. /* redraw everything currently displayed */
  757. void redraw()
  758. {
  759.   touchwin(curscr);
  760.   wrefresh(curscr);
  761. }  
  762.  
  763. /* redraw each permanent window */
  764. void xredraw()
  765. {
  766.   touchwin(Msgw);
  767.   touchwin(Msg3w);
  768.   touchwin(Levelw);
  769.   touchwin(Timew);
  770.   touchwin(Flagw);
  771.   touchwin(Dataw);
  772.   touchwin(Locw);
  773.   touchwin(Morew);
  774.   touchwin(Phasew);
  775.   touchwin(Comwin); 
  776.   wrefresh(Msgw);
  777.   wrefresh(Msg3w);
  778.   wrefresh(Levelw);
  779.   wrefresh(Timew);
  780.   wrefresh(Flagw);
  781.   wrefresh(Dataw);
  782.   wrefresh(Locw);
  783.   wrefresh(Morew);
  784.   wrefresh(Phasew);
  785.   wrefresh(Comwin);
  786. }
  787.  
  788.  
  789.  
  790. void menuaddch(c)
  791. char c;
  792. {
  793.   waddch(Menuw,c);
  794.   wrefresh(Menuw);
  795. }
  796.  
  797.  
  798.  
  799. void morewait()
  800. {
  801.   int display=TRUE;
  802.   char c;
  803.   if (gamestatusp(SUPPRESS_PRINTING))
  804.     return;
  805.   do {
  806.     wclear(Morew);
  807.     if (display) wprintw(Morew,"***  MORE  ***");
  808.     else wprintw(Morew,"+++  MORE  +++");
  809.     display = ! display;
  810.     wrefresh(Morew);
  811.     c = wgetch(Msgw);
  812.   } while ((c != ' ') && (c != RETURN));
  813.   wclear(Morew);
  814.   wrefresh(Morew);
  815. }
  816.  
  817. int stillonblock()
  818. {
  819.   int display=TRUE;
  820.   char c;
  821.   do {
  822.     wclear(Morew);
  823.     if (display) wprintw(Morew,"<<<STAY?>>>");
  824.     else wprintw(Morew,">>>STAY?<<<");
  825.     display = ! display;
  826.     wrefresh(Morew);
  827.     c = wgetch(Msgw);
  828.   } while ((c != ' ') && (c != ESCAPE));
  829.   wclear(Morew);
  830.   wrefresh(Morew);
  831.   return (c == ' ');
  832. }
  833.  
  834. void menuclear()
  835. {
  836.   wclear(Menuw);
  837.   touchwin(Menuw);
  838.   wrefresh(Menuw);
  839. }
  840.  
  841. void menuspellprint(i)
  842. int i;
  843. {
  844.   int x,y;
  845.   getyx(Menuw,&y,&x);
  846.   if (y >= ScreenLength - 2) {
  847.     wrefresh(Menuw);
  848.     morewait();
  849.     wclear(Menuw);
  850.     touchwin(Menuw);
  851.   }
  852.   wprintw(Menuw,spellid(i));
  853.   wprintw(Menuw,"(%d)\n",Spells[i].powerdrain);
  854. }  
  855.  
  856. void menuprint(s)
  857. char *s;
  858. {
  859.   int x,y;
  860.   getyx(Menuw,&y,&x);
  861.   if (y >= ScreenLength - 2) {
  862.     wrefresh(Menuw);
  863.     morewait();
  864.     wclear(Menuw);
  865.     touchwin(Menuw);
  866.   }
  867.   wprintw(Menuw,s);
  868. }
  869.  
  870. void showmenu()
  871. {
  872.   wrefresh(Menuw);
  873. }
  874.  
  875.  
  876. void endgraf()
  877. {
  878.   clear();
  879.   touchwin(stdscr);
  880.   refresh();
  881.   endwin();
  882. }
  883.  
  884.  
  885. void plotchar(pyx,x,y)
  886. short pyx;
  887. int x,y;
  888. {
  889.   if (! offscreen(y)) {
  890.     wmove(Levelw,screenmod(y),x);
  891.     if (optionp(SHOW_COLOUR))
  892.       wattrset(Levelw, pyx>>8);
  893.     waddch(Levelw,(pyx&0xff));
  894.     wrefresh(Levelw);
  895.   }
  896. }
  897.  
  898.  
  899.  
  900. void draw_explosion(pyx,x,y)
  901. short pyx;
  902. int x,y;
  903. {
  904.   int i,j;
  905.   
  906.   for(j=0;j<3;j++) {
  907.     for(i=0;i<9;i++) 
  908.       plotchar(pyx,x+Dirs[0][i],y+Dirs[1][i]);
  909.     usleep(150000);
  910.     for(i=0;i<9;i++)
  911.       plotchar(SPACE,x+Dirs[0][i],y+Dirs[1][i]);
  912.     usleep(150000);
  913.   }
  914.   for(i=0;i<9;i++) 
  915.     plotspot(x+Dirs[0][i],y+Dirs[1][i],TRUE);
  916.   wrefresh(Levelw);
  917. }
  918.  
  919. char *msgscanstring()
  920. {
  921.   static char instring[80],byte='x';
  922.   int i=0;
  923.  
  924.   instring[0]=0;
  925.   byte = mgetc();
  926.   while (byte != '\n') {
  927.     if ((byte == 8) || (byte == 127)) { /* ^h or delete */
  928.       if (i>0){ 
  929.     i--;
  930.     dobackspace();
  931.       }
  932.       instring[i] = 0;
  933.     }
  934.     else {
  935.       instring[i] = byte;
  936.       waddch(Msgw,byte);
  937.       wrefresh(Msgw);
  938.       i++;
  939.       instring[i] = 0;
  940.     }
  941.     byte = mgetc();
  942.   } 
  943.   return(instring);
  944. }
  945.  
  946.  
  947. void locprint(s)
  948. char *s;
  949. {
  950.   wclear(Locw);
  951.   wprintw(Locw,s);
  952.   wrefresh(Locw);
  953. }
  954.  
  955. /* draw everything whether visible or not */
  956. void drawscreen()
  957. {
  958.   int i,j;
  959.   if (Current_Environment == E_COUNTRYSIDE)
  960.     for (i=0;i<WIDTH;i++)
  961.       for(j=0;j<LENGTH;j++)
  962.     c_set(i, j, SEEN);
  963.   else for (i=0;i<WIDTH;i++)
  964.     for(j=0;j<LENGTH;j++)
  965.       lset(i,j,SEEN);
  966.   if (Current_Environment == E_CITY)
  967.     for (i = 0; i < NUMCITYSITES; i++)
  968.       CitySiteList[i][0] = 1;
  969.   show_screen();
  970. }
  971.  
  972. /*selects a number up to range */
  973.  
  974. int getnumber(range)
  975. int range;
  976. {
  977.   int done=FALSE,value=1;
  978.   int atom;
  979.  
  980.   if (range==1) return(1);
  981.   else while (! done) {
  982.     clearmsg();
  983.     wprintw(Msg1w,"How many? Change with < or >, ESCAPE to select:");
  984.     mnumprint(value);
  985. #ifndef MSDOS
  986.     do atom=mcigetc();
  987.     while ((atom != '<')&&(atom != '>')&&(atom!=ESCAPE));
  988.     if ((atom=='>') && (value < range)) value++;
  989.     else if ((atom=='<') && (value > 1)) value--;
  990.     else if (atom==ESCAPE) done = TRUE;
  991. #else
  992.     atom=mcigetc();
  993.     switch (atom)
  994.     {
  995.       case '>':
  996.       case 'k':
  997. #ifdef KEY_UP
  998.       case KEY_UP:
  999. #endif
  1000.         if (value < range)
  1001.       value++;
  1002.     break;
  1003.       case '<':
  1004.       case 'j':
  1005. #ifdef KEY_DOWN
  1006.       case KEY_DOWN:
  1007. #endif
  1008.         if (value > 1)
  1009.       value--;
  1010.     break;
  1011. #ifdef KEY_HOME
  1012.       case KEY_HOME:
  1013. #endif
  1014.         value = 1;
  1015.         break;
  1016. #ifdef KEY_LL
  1017.       case KEY_LL:
  1018. #endif
  1019.         value = range;
  1020.         break;
  1021.       case ESCAPE:
  1022.           done = TRUE;
  1023.     break;
  1024.     }
  1025. #endif
  1026.   }
  1027.   return(value);
  1028. }
  1029.  
  1030. /* reads a positive number up to 999999 */
  1031. long parsenum()
  1032. {
  1033.   int number[8];
  1034.   int place = -1;
  1035.   int i,x,y,mult=1;
  1036.   long num=0;
  1037.   char byte=' ';
  1038.  
  1039.   while ((byte != ESCAPE) && (byte != '\n')) {
  1040.     byte = mgetc();
  1041.     if ((byte == BACKSPACE) || (byte == DELETE)) {
  1042.       if (place > -1) {
  1043.     number[place] = 0;
  1044.     place--;
  1045.     getyx(Msgw,&y,&x);
  1046.     wmove(Msgw,y,x-1);
  1047.     waddch(Msgw,' ');
  1048.     wmove(Msgw,y,x-1);
  1049.     wrefresh(Msgw);
  1050.       }
  1051.     }
  1052.     else if ((byte <= '9') && (byte >= '0') && (place < 7)) {
  1053.       place++;
  1054.       number[place]=byte;
  1055.       waddch(Msgw,byte);
  1056.       wrefresh(Msgw);
  1057.     }
  1058.   }
  1059.   waddch(Msgw,' ');
  1060.   if (byte == ESCAPE) return(ABORT);
  1061.   else {
  1062.     for (i=place;i>=0;i--) {
  1063.       num += mult*(number[i]-'0');
  1064.       mult*=10;
  1065.     }
  1066.     return(num);
  1067.   }
  1068. }
  1069.  
  1070.  
  1071.     
  1072. void maddch(c)
  1073. char c;
  1074. {
  1075.   waddch(Msgw,c);
  1076.   wrefresh(Msgw);
  1077. }
  1078.  
  1079.  
  1080. void display_death(source)
  1081. char *source;
  1082. {
  1083.   clear();
  1084.   touchwin(stdscr);
  1085.   printw("\n\n\n\n");
  1086.   printw("Requiescat In Pace, ");
  1087.   printw(Player.name);
  1088.   printw(" (%ld points)",calc_points());
  1089.   strcpy(Str4,"Killed by ");
  1090.   strcat(Str4,source);
  1091.   printw("\n");
  1092.   printw(Str4);
  1093.   printw(".");
  1094.   printw("\n\n\n\n\nHit 'c' to continue.");
  1095.   refresh();
  1096.   while (wgetch(stdscr) != 'c')
  1097.     ;
  1098.   clear();
  1099.   touchwin(stdscr);
  1100.   refresh();
  1101.   extendlog(Str4,DEAD);
  1102. }
  1103.  
  1104.  
  1105. void display_win()
  1106. {
  1107.   clear();
  1108.   touchwin(stdscr);
  1109.   printw("\n\n\n\n");
  1110.   printw(Player.name);
  1111.   if (Player.rank[ADEPT]) {
  1112.     printw(" is a total master of omega with %ld points!",FixedPoints);
  1113.     strcpy(Str4,"A total master of omega");
  1114.   }
  1115.   else {
  1116.     strcpy(Str4,"retired a winner");
  1117.     printw(" triumphed in omega with %ld points!",calc_points());
  1118.   }
  1119.   printw("\n\n\n\n\nHit 'c' to continue.");
  1120.   refresh();
  1121.   while (wgetch(stdscr) != 'c')
  1122.     ;
  1123.   clear();
  1124.   touchwin(stdscr);
  1125.   refresh();
  1126.   if (Player.rank[ADEPT])
  1127.     extendlog(Str4,BIGWIN);
  1128.   else extendlog(Str4,WIN);
  1129. }
  1130.  
  1131. void display_quit()
  1132. {
  1133.   clear();
  1134.   touchwin(stdscr);
  1135.   printw("\n\n\n\n");
  1136.   printw(Player.name);
  1137.   strcpy(Str4,"A quitter.");
  1138.   printw(" wimped out with %ld points!",calc_points());
  1139.   printw("\n\n\n\n\nHit 'c' to continue.");
  1140.   refresh();
  1141.   while (wgetch(stdscr) != 'c')
  1142.     ;
  1143.   clear();
  1144.   touchwin(stdscr);
  1145.   refresh();
  1146.   extendlog(Str4,QUIT);
  1147. }
  1148.  
  1149.  
  1150. void display_bigwin()
  1151. {
  1152.   clear();
  1153.   touchwin(stdscr);
  1154.   printw("\n\n\n\n");
  1155.   printw(Player.name);
  1156.   strcpy(Str4,"retired, an Adept of Omega.");
  1157.   printw(" retired, an Adept of Omega with %ld points!",FixedPoints);
  1158.   printw("\n\n\n\n\nHit 'c' to continue.");
  1159.   refresh();
  1160.   while (wgetch(stdscr) != 'c')
  1161.     ;
  1162.   clear();
  1163.   touchwin(stdscr);
  1164.   refresh();
  1165.   extendlog(Str4,BIGWIN);
  1166. }
  1167.  
  1168.  
  1169. void mnumprint(n)
  1170. int n;
  1171. {
  1172.   char numstr[20];
  1173.   sprintf(numstr,"%d",n);
  1174.   bufferappend(numstr);
  1175.   wprintw(Msgw,"%d",n);
  1176.   wrefresh(Msgw);
  1177. }
  1178.  
  1179. void mlongprint(n)
  1180. long n;
  1181. {
  1182.   char numstr[20];
  1183.   sprintf(numstr,"%ld",n);
  1184.   bufferappend(numstr);
  1185.   wprintw(Msgw,"%ld",n);
  1186.   wrefresh(Msgw);
  1187. }
  1188.  
  1189.  
  1190. void menunumprint(n)
  1191. int n;
  1192. {
  1193.   int x,y;
  1194.   getyx(Menuw,&y,&x);
  1195.   if (y >= ScreenLength - 2) {
  1196.     wrefresh(Menuw);
  1197.     morewait();
  1198.     wclear(Menuw);
  1199.     touchwin(Menuw);
  1200.   }
  1201.   wprintw(Menuw,"%d",n);
  1202. }
  1203.  
  1204. void menulongprint(n)
  1205. long n;
  1206. {
  1207.   int x,y;
  1208.   getyx(Menuw,&y,&x);
  1209.   if (y >= ScreenLength - 2) {
  1210.     wrefresh(Menuw);
  1211.     morewait();
  1212.     wclear(Menuw);
  1213.     touchwin(Menuw);
  1214.   }
  1215.   wprintw(Menuw,"%ld",n);
  1216. }
  1217.  
  1218.  
  1219. void dobackspace()
  1220. {
  1221.   int x,y;
  1222.  
  1223.   getyx(Msgw,&y,&x);
  1224.   if (x > 0) {
  1225.     waddch(Msgw,' ');
  1226.     wmove(Msgw,y,x-1);
  1227.     waddch(Msgw,' ');
  1228.     wmove(Msgw,y,x-1);
  1229.   }
  1230.   wrefresh(Msgw);
  1231. }
  1232.  
  1233.  
  1234. void showflags()
  1235. {
  1236.  
  1237.   phaseprint();
  1238.   wclear(Flagw);
  1239.   if (Player.food < 0)
  1240.     wprintw(Flagw,"Starving\n");
  1241.   else if (Player.food <= 3)
  1242.     wprintw(Flagw,"Weak\n");
  1243.   else if (Player.food <= 10)
  1244.     wprintw(Flagw,"Ravenous\n");
  1245.   else if (Player.food <= 20)
  1246.     wprintw(Flagw,"Hungry\n");
  1247.   else if (Player.food <= 30)
  1248.     wprintw(Flagw,"A mite peckish\n");
  1249.   else if (Player.food <= 36)
  1250.     wprintw(Flagw,"Content\n");
  1251.   else if (Player.food <= 44)
  1252.     wprintw(Flagw,"Satiated\n");
  1253.   else wprintw(Flagw,"Bloated\n");
  1254.  
  1255.  
  1256.   if (Player.status[POISONED]>0)
  1257.     wprintw(Flagw,"Poisoned\n");
  1258.   else wprintw(Flagw,"Vigorous\n");
  1259.  
  1260.   if (Player.status[DISEASED]>0)
  1261.     wprintw(Flagw,"Diseased\n");
  1262.   else wprintw(Flagw,"Healthy\n");
  1263.  
  1264.   if (gamestatusp(MOUNTED)) wprintw(Flagw,"Mounted\n");
  1265.   else if (Player.status[LEVITATING]) wprintw(Flagw,"Levitating\n");
  1266.   else wprintw(Flagw,"Afoot\n");
  1267.  
  1268.   wrefresh(Flagw);
  1269. }
  1270.  
  1271. void drawomega()
  1272. {
  1273.   int i;
  1274.   clear();
  1275.   touchwin(stdscr);
  1276.   for(i=0;i<7;i++) {
  1277.       move(1, 1);
  1278.       if (optionp(SHOW_COLOUR))
  1279.         wattrset(stdscr, COL_LIGHT_BLUE>>8);
  1280.       printw("\n\n\n");
  1281.       printw("\n                                    *****");
  1282.       printw("\n                               ******   ******");
  1283.       printw("\n                             ***             ***");
  1284.       printw("\n                           ***                 ***");
  1285.       printw("\n                          **                     **");
  1286.       printw("\n                         ***                     ***");
  1287.       printw("\n                         **                       **");
  1288.       printw("\n                         **                       **");
  1289.       printw("\n                         ***                     ***");
  1290.       printw("\n                          ***                   ***");
  1291.       printw("\n                            **                 **");
  1292.       printw("\n                       *   ***                ***   *");
  1293.       printw("\n                        ****                    ****");
  1294.       refresh();
  1295.       usleep(200000);
  1296.       move(1, 1);
  1297.       if (optionp(SHOW_COLOUR))
  1298.         wattrset(stdscr, COL_CYAN>>8);
  1299.       printw("\n\n\n");
  1300.       printw("\n                                    +++++");
  1301.       printw("\n                               ++++++   ++++++");
  1302.       printw("\n                             +++             +++");
  1303.       printw("\n                           +++                 +++");
  1304.       printw("\n                          ++                     ++");
  1305.       printw("\n                         +++                     +++");
  1306.       printw("\n                         ++                       ++");
  1307.       printw("\n                         ++                       ++");
  1308.       printw("\n                         +++                     +++");
  1309.       printw("\n                          +++                   +++");
  1310.       printw("\n                            ++                 ++");
  1311.       printw("\n                       +   +++                +++   +");
  1312.       printw("\n                        ++++                    ++++");
  1313.       refresh();
  1314.       usleep(200000);
  1315.       move(1, 1);
  1316.       if (optionp(SHOW_COLOUR))
  1317.         wattrset(stdscr, COL_BLUE>>8);
  1318.       printw("\n\n\n");
  1319.       printw("\n                                    .....");
  1320.       printw("\n                               ......   ......");
  1321.       printw("\n                             ...             ...");
  1322.       printw("\n                           ...                 ...");
  1323.       printw("\n                          ..                     ..");
  1324.       printw("\n                         ...                     ...");
  1325.       printw("\n                         ..                       ..");
  1326.       printw("\n                         ..                       ..");
  1327.       printw("\n                         ...                     ...");
  1328.       printw("\n                          ...                   ...");
  1329.       printw("\n                            ..                 ..");
  1330.       printw("\n                       .   ...                ...   .");
  1331.       printw("\n                        ....                    ....");
  1332.       refresh();
  1333.       usleep(200000);
  1334.   }
  1335.   wattrset(stdscr, COL_WHITE>>8);
  1336. }
  1337.  
  1338. /* y is an absolute coordinate */
  1339. /* ScreenOffset is the upper left hand corner of the current screen
  1340.    in absolute coordinates */
  1341.  
  1342. void screencheck(y)
  1343. int y;
  1344. {
  1345.   if (((y-ScreenOffset) < (ScreenLength/8)) ||
  1346.       ((y-ScreenOffset) > (7*ScreenLength/8))) {
  1347.     ScreenOffset = y - (ScreenLength/2);
  1348.     show_screen();
  1349.     if (Current_Environment != E_COUNTRYSIDE) 
  1350.       drawmonsters(TRUE);
  1351.     if (!offscreen(Player.y))
  1352.       drawplayer();
  1353.   }
  1354. }
  1355.  
  1356.  
  1357.  
  1358.  
  1359. void spreadroomlight(x,y,roomno)
  1360. int x,y,roomno;
  1361. {
  1362.   if (inbounds(x,y) && !loc_statusp(x,y,LIT) &&
  1363.       Level->site[x][y].roomnumber == roomno) {
  1364.     lightspot(x,y);
  1365.     spreadroomlight(x+1,y,roomno);
  1366.     spreadroomlight(x,y+1,roomno);
  1367.     spreadroomlight(x-1,y,roomno);
  1368.     spreadroomlight(x,y-1,roomno);
  1369.   }
  1370. }
  1371.  
  1372. /* illuminate one spot at x y */
  1373. void lightspot(x,y)
  1374. int x,y;
  1375.   short c;
  1376.   lset(x,y,LIT);
  1377.   lset(x,y,SEEN);
  1378.   lset(x, y, CHANGED);
  1379.   c = getspot(x,y,FALSE);
  1380.   Level->site[x][y].showchar = c;
  1381.   putspot(x,y,c);
  1382. }
  1383.  
  1384.  
  1385.  
  1386. void spreadroomdark(x,y,roomno)
  1387. int x,y,roomno;
  1388. {
  1389.   if (inbounds(x,y))
  1390.     if (loc_statusp(x,y,LIT) && (Level->site[x][y].roomnumber == roomno)) {
  1391.       blankoutspot(x,y);
  1392.       spreadroomdark(x+1,y,roomno);
  1393.       spreadroomdark(x,y+1,roomno);
  1394.       spreadroomdark(x-1,y,roomno);
  1395.       spreadroomdark(x,y-1,roomno);
  1396.     }
  1397. }
  1398.  
  1399.  
  1400.  
  1401.  
  1402. void display_pack()
  1403. {
  1404.   int i;
  1405.   if (Player.packptr < 1) print3("Pack is empty.");
  1406.   else {
  1407.     menuclear();
  1408.     menuprint("Items in Pack:\n");
  1409.     for(i=0;i<Player.packptr;i++) {
  1410.       sprintf(Str1, "  %c: %s\n", i + 'A', itemid(Player.pack[i]));
  1411.       menuprint(Str1);
  1412.     }
  1413.     showmenu();
  1414.   }
  1415. }
  1416.  
  1417.  
  1418. void display_possessions()
  1419. {
  1420.   int i;
  1421.   for(i=0;i<MAXITEMS;i++) 
  1422.     display_inventory_slot(i,FALSE);
  1423. }
  1424.  
  1425.  
  1426. void display_inventory_slot(slotnum,topline)
  1427. int slotnum;
  1428. int topline;
  1429. {
  1430.   WINDOW *W;
  1431.   char usechar = ')';
  1432.   if (Player.possessions[slotnum] != NULL)
  1433.     if (Player.possessions[slotnum]->used)
  1434.       usechar = '>';
  1435.   if (topline) W = Msg3w;
  1436.   else {
  1437.     W = Showline[slotnum];
  1438.     hide_line(slotnum);
  1439.   }
  1440.   touchwin(W);
  1441.   wclear(W);
  1442.   switch(slotnum) {
  1443.   case O_UP_IN_AIR:
  1444.     wprintw(W,"-- Object 'up in air':",usechar);
  1445.     break;
  1446.   case O_READY_HAND:
  1447.     wprintw(W,"-- a%c ready hand: ",usechar);
  1448.     break;
  1449.   case O_WEAPON_HAND:
  1450.     wprintw(W,"-- b%c weapon hand: ",usechar);
  1451.     break;
  1452.   case O_LEFT_SHOULDER:
  1453.     wprintw(W,"-- c%c left shoulder: ",usechar);
  1454.     break;
  1455.   case O_RIGHT_SHOULDER:
  1456.     wprintw(W,"-- d%c right shoulder: ",usechar);
  1457.     break;
  1458.   case O_BELT1:
  1459.     wprintw(W,"-- e%c belt: ",usechar);
  1460.     break;
  1461.   case O_BELT2:
  1462.     wprintw(W,"-- f%c belt: ",usechar);
  1463.     break;
  1464.   case O_BELT3:
  1465.     wprintw(W,"-- g%c belt: ",usechar);
  1466.     break;
  1467.   case O_SHIELD:
  1468.     wprintw(W,"-- h%c shield: ",usechar);
  1469.     break;
  1470.   case O_ARMOR:
  1471.     wprintw(W,"-- i%c armor: ",usechar);
  1472.     break;
  1473.   case O_BOOTS:
  1474.     wprintw(W,"-- j%c boots: ",usechar);
  1475.     break;
  1476.   case O_CLOAK:
  1477.     wprintw(W,"-- k%c cloak: ",usechar);
  1478.     break;
  1479.   case O_RING1:
  1480.     wprintw(W,"-- l%c finger: ",usechar);
  1481.     break;
  1482.   case O_RING2:
  1483.     wprintw(W,"-- m%c finger: ",usechar);
  1484.     break;
  1485.   case O_RING3:
  1486.     wprintw(W,"-- n%c finger: ",usechar);
  1487.     break;
  1488.   case O_RING4:
  1489.     wprintw(W,"-- o%c finger: ",usechar);
  1490.     break;
  1491.   }
  1492.   if (Player.possessions[slotnum]== NULL)
  1493.     wprintw(W,"(slot vacant)");
  1494.   else wprintw(W,itemid(Player.possessions[slotnum]));
  1495.   wrefresh(W);
  1496. }
  1497.  
  1498. int move_slot(oldslot,newslot,maxslot)
  1499. int oldslot,newslot,maxslot;
  1500. {
  1501.   if ((newslot >= 0) && (newslot < maxslot)){
  1502.     wmove(Showline[oldslot],0,0);
  1503.     waddstr(Showline[oldslot],"--");
  1504.     wrefresh(Showline[oldslot]);
  1505.     wmove(Showline[newslot],0,0);
  1506.     wstandout(Showline[newslot]);
  1507.     waddstr(Showline[newslot],">>");
  1508.     wstandend(Showline[newslot]);
  1509.     wrefresh(Showline[newslot]);
  1510.     return(newslot);
  1511.   }
  1512.   else return(oldslot);
  1513. }
  1514.  
  1515. void colour_on()
  1516. {
  1517. }
  1518.  
  1519. void colour_off()
  1520. {
  1521.   wattrset(Levelw, COL_WHITE>>8);
  1522. }
  1523.  
  1524. void display_option_slot(slot)
  1525. int slot;
  1526. {
  1527.   hide_line(slot);
  1528.   wclear(Showline[slot]);
  1529.   switch(slot) {
  1530.   case 1:
  1531.     wprintw(Showline[slot],"-- Option BELLICOSE [TF]: ");
  1532.     wprintw(Showline[slot], optionp(BELLICOSE) ? "(now T) " : "(now F) ");
  1533.     break;
  1534.   case 2:
  1535.     wprintw(Showline[slot],"-- Option JUMPMOVE [TF]: ");
  1536.     wprintw(Showline[slot], optionp(JUMPMOVE) ? "(now T) " : "(now F) ");
  1537.     break;
  1538.   case 3:
  1539.     wprintw(Showline[slot],"-- Option RUNSTOP [TF]: ");
  1540.     wprintw(Showline[slot], optionp(RUNSTOP) ? "(now T) " : "(now F) ");
  1541.     break;
  1542.   case 4:
  1543.     wprintw(Showline[slot],"-- Option PICKUP [TF]: ");
  1544.     wprintw(Showline[slot], optionp(PICKUP) ? "(now T) " : "(now F) ");
  1545.     break;
  1546.   case 5:
  1547.     wprintw(Showline[slot],"-- Option CONFIRM [TF]: ");
  1548.     wprintw(Showline[slot], optionp(CONFIRM) ? "(now T) " : "(now F) ");
  1549.     break;
  1550.   case 6:
  1551.     wprintw(Showline[slot],"-- Option TOPINV [TF]: ");
  1552.     wprintw(Showline[slot], optionp(TOPINV) ? "(now T) " : "(now F) ");
  1553.     break;
  1554.   case 7:
  1555.     wprintw(Showline[slot],"-- Option PACKADD [TF]: ");
  1556.     wprintw(Showline[slot], optionp(PACKADD) ? "(now T) " : "(now F) ");
  1557.     break;
  1558.   case 8:
  1559. #ifdef COMPRESS_SAVE_FILES
  1560.     wprintw(Showline[slot],"-- Option COMPRESS [TF]: ");
  1561.     wprintw(Showline[slot], optionp(COMPRESS_OPTION) ? "(now T) " : "(now F) ");
  1562. #endif
  1563.     break;
  1564.   case 9:
  1565. #if defined(MSDOS) || defined(AMIGA)
  1566.     wprintw(Showline[slot],"-- Option COLOUR [TF]: ");
  1567.     wprintw(Showline[slot], optionp(SHOW_COLOUR) ? "(now T) " : "(now F) ");
  1568. #endif
  1569.     break;
  1570.   case VERBOSITY_LEVEL:
  1571.     wprintw(Showline[slot],
  1572.         "-- Option VERBOSITY [(T)erse,(M)edium,(V)erbose]: (now ");
  1573.     if (Verbosity == VERBOSE) wprintw(Showline[slot],"Verbose)");
  1574.     else if (Verbosity == MEDIUM) wprintw(Showline[slot],"Medium)");
  1575.     else wprintw(Showline[slot],"Terse)");
  1576.     break;
  1577.   case SEARCH_DURATION:
  1578.     wprintw(Showline[slot],"-- Option SEARCHNUM [0>x>10]: (now %d)",Searchnum);
  1579.     break;
  1580.   }
  1581.   wrefresh(Showline[slot]);
  1582. }
  1583.  
  1584.  
  1585. void display_options()
  1586. {
  1587.   int i;
  1588.   menuclear();
  1589.   hide_line(0);
  1590.   for(i=1;i<=NUMOPTIONS;i++)
  1591.     display_option_slot(i);
  1592. }
  1593.  
  1594.  
  1595. /* nya ha ha ha ha haaaa.... */
  1596. void deathprint()
  1597. {
  1598.   mgetc();
  1599.   waddch(Msgw,'D');
  1600.   wrefresh(Msgw);
  1601.   mgetc();
  1602.   waddch(Msgw,'e');
  1603.   wrefresh(Msgw);
  1604.   mgetc();
  1605.   waddch(Msgw,'a');
  1606.   wrefresh(Msgw);
  1607.   mgetc();
  1608.   waddch(Msgw,'t');
  1609.   wrefresh(Msgw);
  1610.   mgetc();
  1611.   waddch(Msgw,'h');
  1612.   wrefresh(Msgw);
  1613.   mgetc();
  1614. }
  1615.   
  1616. void clear_if_necessary()
  1617. {
  1618.   int x,y;
  1619.   getyx(Msg1w,&y,&x);
  1620.  
  1621.   if (x != 0) {
  1622.     wclear(Msg1w);
  1623.     wrefresh(Msg1w);
  1624.   }  
  1625.  
  1626.   getyx(Msg2w,&y,&x);
  1627.  
  1628.   if (x != 0) {
  1629.     wclear(Msg2w);
  1630.     wrefresh(Msg2w);
  1631.   }  
  1632.  
  1633.   getyx(Msg3w,&y,&x);
  1634.  
  1635.   if (x != 0) {
  1636.     wclear(Msg3w);
  1637.     wrefresh(Msg3w);
  1638.   }
  1639.  
  1640. }
  1641.  
  1642. int bufferpos = 0;
  1643.  
  1644. void buffercycle(s)
  1645. char *s;
  1646. {
  1647.   strcpy(Stringbuffer[bufferpos++],s);
  1648.   if (bufferpos >= STRING_BUFFER_SIZE)
  1649.     bufferpos = 0;
  1650. }
  1651.  
  1652. int bufferappend(s)
  1653. char *s;
  1654. {
  1655.   int pos = bufferpos - 1;
  1656.  
  1657.   if (pos < 0)
  1658.     pos = STRING_BUFFER_SIZE - 1;
  1659.   if (strlen(Stringbuffer[pos]) + strlen(s) < 80 - 1) {
  1660.     strcat(Stringbuffer[pos],s);
  1661.     return 1;
  1662.   }
  1663.   else
  1664.     return 0;
  1665. }
  1666.  
  1667.  
  1668. void bufferprint()
  1669. {
  1670.   int i = bufferpos - 1, c, finished = 0;
  1671.   clearmsg();
  1672. #ifndef MSDOS
  1673.   wprintw(Msg1w,"^p for previous message, ^n for next, anything else to quit.");
  1674. #else
  1675.   wprintw(Msg1w,"^o for last message, ^n for next, anything else to quit.");
  1676. #endif
  1677.   wrefresh(Msg1w);
  1678.   do {
  1679.     if (i >= STRING_BUFFER_SIZE) i = 0;
  1680.     if (i < 0) i = STRING_BUFFER_SIZE - 1;
  1681.     wclear(Msg2w);
  1682.     wprintw(Msg2w,Stringbuffer[i]);
  1683.     wrefresh(Msg2w);
  1684.     c = mgetc();
  1685. #ifndef MSDOS
  1686.     if (c == 16)    /* ^p */
  1687. #else
  1688.     if (c == 15)    /* ^o */
  1689. #endif
  1690.       i--;
  1691.     else if (c == 14)    /* ^n */
  1692.       i++;
  1693.     else
  1694.       finished = 1;
  1695.   } while (!finished);
  1696.   clearmsg();
  1697.   omshowcursor(Player.x,Player.y);
  1698. }
  1699.  
  1700. void clear_screen()
  1701. {
  1702.   clear();
  1703.   touchwin(stdscr);
  1704.   refresh();
  1705. }
  1706.  
  1707. #if !defined(MSDOS) && !defined(AMIGA)
  1708. /* this function will never be called if we're neither MSDOS nor AMIGA, */
  1709. /* but the linker needs something, naturally... */
  1710. void wattrset(WINDOW *w, int s)
  1711. {
  1712. }
  1713. #endif
  1714.